
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
/**
 *
 * @date 2020/8/6 16:17
 * @author dmc
 * @version 1.0
 */
public class jdbcapp {

    public static void main(String[] args) throws Exception {


        /**
         * - 加载JDBC驱动程序
         * - 创建数据库连接
         * - 创建preparedStatement
         * - 执行SQL
         * - 处理结果集
         * - 关闭JDBC对象资源
         */


        Class.forName("com.mysql.cj.jdbc.Driver");

        String url = "jdbc:mysql://127.0.0.1:3306/xdclass?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=false";
        String username = "root";
        String password = "dmc";

        //获取连接对象,连接数据库
       Connection connection =  DriverManager.getConnection(url,username,password);

        //获取语句对象,
        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery("select count (*) from video group by ;");

        while (resultSet.next()){
            System.out.println("视频标题"+resultSet.getString("title"));
        }
        statement.closeOnCompletion();



    }
}
